/**
 * By Alpha
 * Author: alixez <alixe.z@foxmail.com>
 * Date: 2017/11/2
 */
const nodeEnv = process.env.NODE_ENV;
let { apiVersion } = require('../../package.json');

if (!apiVersion) {
  apiVersion = (nodeEnv === 'development' ? 'mock' : 'release');
}

const GetAPIPrefix = (version) => {
  const prefix = {
    release: '/api',
    mock: '/api/mock',
    v1: '/api/v1',
    v2: '/api/v2',
  }[version];

  if (!prefix) {
    return `/api/${apiVersion}`;
  }

  return prefix;
};

export const mockAPIPrefix = GetAPIPrefix('mock');
export const APIPrefix = GetAPIPrefix("v1");

export default {
  dashboard: `${APIPrefix}/dashboard`,
  authorization: {
    login: `${APIPrefix}/login`,
    logout: `${APIPrefix}/logout`,
  },
  user: {
    get: `${APIPrefix}/user/info`,
    profile: `${mockAPIPrefix}/user/profile`,
    list: `${mockAPIPrefix}/user/list`,
    remove: `${mockAPIPrefix}/user/remove`,

    // 获取当前部门所有用户
    getUsersByDept: `${APIPrefix}/user/allUsersByDept`,

    // 获取当前组织内所有用户
    allUser: `${APIPrefix}/user/allUser`,
  },

  // 团员
  member: {
    query: `${APIPrefix}/user/getAllMembers`,
    details: `${mockAPIPrefix}/member/details`,
  },
  menus: `${mockAPIPrefix}/menus`,
  // 工作通知
  worknotice: {
    list: `${APIPrefix}/todoList/list`,
    create: `${APIPrefix}/todoList/create`,
    remove: `${APIPrefix}/todoList/remove`,
    batchRemove: `${APIPrefix}/todoList/batchRemove`,
  },
  // 通讯录
  addresslist: {
    list: `${mockAPIPrefix}/addresslist/list`,
  },
  // 经费
  expenditure: {
    list: `${mockAPIPrefix}/expenditure/list`,
    details: `${mockAPIPrefix}/expenditure/details`,
  },
  // 活动
  activity: {
    list: `${mockAPIPrefix}/activity/list`,
    details: `${mockAPIPrefix}/activity/details`,
  },
  // 物品借用
  itemsborrowed: {
    list: `${mockAPIPrefix}/itemsborrowed/list`,
    details: `${mockAPIPrefix}/itemsborrowed/details`,
  },
  // 注册
  register: {
    school: `${APIPrefix}/school/allSchools`,
    doRegister: `${APIPrefix}/register`,
  },
  // 手机验证码
  code: `${APIPrefix}/sms/sendVerifyCode`,
  // 修改密码
  forgetPassword: {
    doforget: `${APIPrefix}/user/forgetPassword`,
  },
  // 社团管理
  organization: {
    doCreate: `${APIPrefix}/organization/createOrganization`,
    doJoin: `${APIPrefix}/organization/join`,
    getCommunity: `${mockAPIPrefix}/organization/community`,
  },
  // 上传文件
  uploadfiles: `${APIPrefix}/file/uploadSingleFile`,
  // 资源库

  // 审批

  // 部门
  department: {
    allDepts: `${APIPrefix}/department/getAllDepartmentByOrg`,
    createDept: `${APIPrefix}/department/addDept`,
    addUserToDept: `${APIPrefix}/department/addUserToDepartment`,
    removeUserFromDept: `${APIPrefix}/department/removeUserFromDepartment`,
    allCanSelectedUsers: `${APIPrefix}/department/allCanSelectedUsers`,
    getUsersWithDepartment: `${APIPrefix}/department/getAllUsersWithDepartment`,
  },

  // 职位相关接口
  jobs: {
    createJob: `${APIPrefix}/job/createJob`,
    getUsersWithJob: `${APIPrefix}/job/getUsersWithJob`,
    allCanSelectedUsers: `${APIPrefix}/job/allCanSelectedUsers`,
    addUsersToJob: `${APIPrefix}/job/addUsersToJob`,
    removeUsersFromJob: `${APIPrefix}/job/removeUsersFromJob`,
    getAllJobs: `${APIPrefix}/job/getAllJobs`,
  },

  roles: {
    createRoleOrGroup: `${APIPrefix}/role/createRoleOrGroup`,
    addUsersToRole: `${APIPrefix}/role/addUsersToRole`,
    removeUsersFromRole: `${APIPrefix}/role/removeUsersFromRole`,
    getUsersInRole: `${APIPrefix}/role/getUsersInRole`,
    getAllCanUseRoles: `${APIPrefix}/role/getAllCanUseRoles`,
  },
  
};
